﻿#ifndef RISC_H
#define RISC_H

#include "pagetype.h"

using PageItem_RISC = std::pair<uint64_t, RISC_Page>;
struct PTE_RISC
{
	PageItem_RISC items[8];
};

class TLB_RISC : public TLB
{
private:
	uint64_t satp;
	PTE_RISC l1i_4k[4], l1i_2m, l1i_1g;
	PTE_RISC l1d_4k[8], l1d_2m[2], l1d_1g[2];
	PTE_RISC l2_4k[128], l2_2m[64], l2_1g[64];
	void l1i_search();
	void l1d_search();
	void l2_search();
	void swap();

public:
	TLB_RISC() = default;
	~TLB_RISC() = default;
	void init(uint64_t satp) { this->satp = satp; }
	void tick();
	void reset();
};

#endif